Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

135
Views
Error de tipo de flujo: "el número [1] es incompatible con `Number` [2] en la propiedad `index`" - usando el contexto de React

usando React context y creo que la razón por la que podría no funcionar es por un problema de tipo en el archivo Context. El asunto dice:

No se puede llamar a createContext con el objeto literal vinculado a defaultValue porque el número [1] es incompatible con el Number [2] en el index de propiedad .Flow(incompatible-call)

 // @flow import React, { createContext, useContext } from "react"; export type CountryIndexProviderType = { index: Number, }; const CountryContext = createContext<CountryIndexProviderType>({ index: 0, }); type CountryContextProviderProps = { index: Number, }; const CountryContextProvider = ({ index }: CountryContextProviderProps) => { return <CountryContext.Provider value={{ index }}></CountryContext.Provider>; }; const useCountryIndexContext = () => useContext(CountryContext); export { CountryContext, CountryContextProvider, useCountryIndexContext };

COMPONENTE 1:

 import { CountryContextProvider } from "/EnteredCountriesContext"; return ( <StyledWrappingContainer> <StyledProgress>{index + 2}</StyledProgress> <CountryContextProvider index={index}></CountryContextProvider> </StyledWrappingContainer> );

COMPONENTE 2:

 import { useCountryIndexContext } from "/EnteredCountriesContext"; const { index } = useCountryIndexContext(); <StyledWrappingContainer> <StyledProgress> <StyledProgress>{index + 2}</StyledProgress> </StyledProgress> </StyledWrappingContainer>

¿Alguien puede detectar cuál podría ser mi problema?

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

Necesitas cambiar

 index: Number,

ser - estar

 index: number,

Un Number es un objeto, number es un tipo primitivo.

about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!